package com.by.service.impl;

import com.by.bean.Dic;
import com.by.bean.PageBean;
import com.by.mapper.DicMapper;
import com.by.query.DicQuery;
import com.by.service.DicService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;
import java.util.Map;

/**
 * date 2025/2/24 15:38
 * author bjj
 * decoration
 * version 1.0
 * since jdk11
 */
@Service
public class DicServiceImpl implements DicService {
    @Autowired
    DicMapper dicMapper;
    /**
     * 分页查询
     * @param dicQuery
     * @return
     */
    @Override
    public PageBean query(DicQuery dicQuery) {
        PageHelper.startPage(dicQuery.getPage(),dicQuery.getPageSize());
        List list = dicMapper.query(dicQuery);
        PageInfo pageInfo = new PageInfo(list);
        return new PageBean(dicQuery.getPage(), dicQuery.getPageSize(), pageInfo.getTotal(), list);
    }

    @Override
    public int save(Dic dic) {
        return dicMapper.save(dic);
    }

    @Override
    public int update(Dic dic) {
        return dicMapper.update(dic);
    }

    @Override
    public List<Map> queryById(int pid) {
        return dicMapper.queryById(pid);
    }

    @Override
    public int delete(int id) {
        return dicMapper.delete(id);
    }
}
